/*
 * Copyright (c) 2010 CCX(China) Co.,Ltd. All Rights Reserved.
 *
 * This software is the confidential and proprietary information of
 * CCX(China) Co.,Ltd. ("Confidential Information").
 * It may not be copied or reproduced in any manner without the express 
 * written permission of CCX(China) Co.,Ltd.
 *
 * Author: zhnb
 * Date: 2011-8-18 上午10:20:44
 */
package com.ccx.service;

import java.io.Serializable;

import Ice.Application;

import com.ccx.dto.ADTO;
import com.ccx.dto.ADTOHolder;

public class ParamTestClient extends Application implements Serializable {

    private static final long serialVersionUID = -5770170281165953926L;

    @Override
    public int run(String[] args) {
        if (args.length > 0) {
            System.out.println(appName() + ": too many arguments");
            return 1;
        }
        
//        // * 添加自定义类
//        Ice.ObjectFactory factory = new ParamTestFactory();
//        communicator().addObjectFactory(factory, "::dto::ADTO");

        Ice.Properties properties = communicator().getProperties();
        
        StringBuffer buff = new StringBuffer();
        buff.append(properties.getProperty("MyApp.uuId"));
        buff.append(":");
        buff.append(properties.getProperty("MyAppServer.Endpoints"));
        
        ParamTestPrx paramTestPrx = null;
        
        System.out.println(buff.toString());
        
        paramTestPrx = ParamTestPrxHelper.checkedCast(communicator().stringToProxy(buff.toString()));
        
        // 测试状态，0则正常
        int status = paramTestPrx.getStatus();
        System.out.println(status);

        // 发送ADTO数据
        ADTOHolder aDTOHolder = new ADTOHolder();
        ADTO aDTO = new ADTO();
        aDTO.str = "ParamTestClient";
        aDTO.mark = false;
        aDTOHolder.value = aDTO;
        
        System.out.println(aDTOHolder.value.str + ":" + aDTOHolder.value.mark);
        paramTestPrx.changeParam(aDTOHolder);
        System.out.println(aDTOHolder.value.str + ":" + aDTOHolder.value.mark);
        
        return 0;
    }
    
    public static void main(String[] args) {
        ParamTestClient paramTestClient = new ParamTestClient();
        int status = paramTestClient.main("ParamTestClient", args, "com/ccx/service/common-server.config");
        System.exit(status);
        
    }

}
